(function(){"use strict";BX.namespace("BX.Landing.UI.Panel");BX.Landing.UI.Panel.Unsplash=function(n){if(BX.Landing.UI.Panel.Unsplash.instance){return BX.Landing.UI.Panel.Unsplash.instance}BX.Landing.UI.Panel.Content.apply(this,arguments);this.onChangeHandler=null;this.onSearchWithDebounce=BX.debounce(this.onSearchWithDebounce,1e3,this);this.layout.classList.add("landing-ui-panel-unsplash");this.searchContainer=BX.create("div",{props:{className:"landing-ui-panel-unsplash-search-container"}});this.loader=BX.create("div",{props:{className:"landing-ui-panel-unsplash-search-loader-container"}});this.loader.appendChild(BX.create("div",{props:{className:"landing-ui-panel-unsplash-search-loader"}}));(this.searchInputField=new BX.Landing.UI.Field.Unit({onInput:this.onSearchInput.bind(this),className:"landing-ui-panel-unsplash-search-field",placeholder:BX.Landing.Loc.getMessage("UNSPLASH_SEARCH_FIELD_PLACEHOLDER"),title:BX.Landing.Loc.getMessage("UNSPLASH_SEARCH_FIELD_LABEL")})).enableTextOnly();this.searchContainer.appendChild(this.searchInputField.layout);this.content.appendChild(this.searchContainer);this.searchInputField.input.type="text";this.searchInputField.input.min=null;this.searchInputField.input.max=null;this.content.appendChild(this.loader);this.imagesList=BX.create("div",{props:{className:"landing-ui-panel-unsplash-images-list"}});this.content.appendChild(this.imagesList);document.body.appendChild(this.layout);this.makeLayouts()};BX.Landing.UI.Panel.Unsplash.instance=null;BX.Landing.UI.Panel.Unsplash.getInstance=function(){if(!BX.Landing.UI.Panel.Unsplash.instance){BX.Landing.UI.Panel.Unsplash.instance=new BX.Landing.UI.Panel.Unsplash("unsplash")}return BX.Landing.UI.Panel.Unsplash.instance};BX.Landing.UI.Panel.Unsplash.prototype={constructor:BX.Landing.UI.Panel.Unsplash,__proto__:BX.Landing.UI.Panel.Content.prototype,show:function(n){BX.Landing.UI.Panel.Content.prototype.show.call(this);this.onChangeHandler=n},hide:function(){BX.Landing.UI.Panel.Content.prototype.hide.call(this);this.onChangeHandler=null},showLoader:function(){this.imagesList.innerHTML="";this.loader.classList.add(this.classShow)},hideLoader:function(){this.loader.classList.remove(this.classShow)},isLoaderShown:function(){return this.loader.classList.contains(this.classShow)},onSearchInput:function(n){var a=n.getValue();if(!!a&&a.length){this.showLoader();this.onSearchWithDebounce(a)}else{this.makeLayouts()}},onSearchWithDebounce:function(n){var a=new BX.Landing.Client.Unsplash.getInstance;a.search(n).then(function(n){this.hideLoader();this.imagesList.innerHTML="";n.forEach(function(n){var a=new BX.Landing.UI.Card.ImagePreview({image:n.urls.small,onClick:function(){this.onChange(n.urls.full)}.bind(this)});this.imagesList.appendChild(a.layout)},this)}.bind(this))},makeLayouts:function(){var n=new BX.Landing.Client.Unsplash.getInstance;this.showLoader();n.popular().then(function(n){this.hideLoader();this.imagesList.innerHTML="";n.forEach(function(n){var a=new BX.Landing.UI.Card.ImagePreview({image:n.urls.small,onClick:function(){this.onChange(n.urls.full)}.bind(this)});this.imagesList.appendChild(a.layout)},this)}.bind(this))},onChange:function(n){if(typeof this.onChangeHandler==="function"){this.onChangeHandler(n)}this.hide()}}})();
//# sourceMappingURL=unsplash_panel.map.js